/*
 * @lc app=leetcode.cn id=35 lang=typescript
 *
 * [35] 搜索插入位置
 */

// @lc code=start
function searchInsert(nums: number[], target: number): number {
    const index = nums.findIndex(r => r === target)
    if (index > -1) {
        return index;
    } else {
        nums.push(target);
        nums.sort();
        return nums.findIndex(r => r === target)
    }
};
// @lc code=end

